package ui.server;

import ui.client.InstantMessage;
import ui.client.UserPresence;



/**
 * the class of MyEventHandler implements ProtocolEventHandler
 * and will receive the message and presence information
 * @author wangkaidi
 *
 */
public class MyEventHandler implements ProtocolEventHandler
{
	private String sessionid;//sessionid to identify
	public MyEventHandler(String sessionid)
	{		
		this.sessionid=sessionid;
	}
	
	public void messageArrived(InstantMessage message) 
	{		
		InstantMessage mm=new InstantMessage(message.getFromID(),message.getDestinationID(),message.getContent());		
		ConnectionManager.getInstance().addMessage(sessionid, mm);//add a message to the Message list W
	}

	public void presenceChanged(UserPresence presence) 
	{		
		ConnectionManager.getInstance().addPresence(sessionid, presence);
	}

	
	public void connectFailed() {
		// TODO Auto-generated method stub
		
	}


	public void loggedIn() {
		// TODO Auto-generated method stub
		
	}

	
	public void loginFailed() {
		// TODO Auto-generated method stub
		
	}
	
}
